package com.mall.vo;

import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

/**
 * 商品VO
 * 
 * @author Mall Team
 */
@Data
public class ProductVO {
    
    private Long id;
    private String name;
    private Long categoryId;
    private String categoryName;
    private String brand;
    private BigDecimal price;
    private Integer stock;
    private String description;
    private String mainImage;
    private List<String> images;  // 图片列表
    private Integer status;
    private String statusDesc;
    private LocalDateTime createTime;
    private LocalDateTime updateTime;
    
    // 扩展字段
    private Long salesCount;      // 销量
    private Boolean isRecommend;  // 是否推荐
    private Boolean isFavorite;   // 是否收藏（需要用户登录）
    
    /**
     * 商品简要信息VO（用于列表展示）
     */
    @Data
    public static class ProductListVO {
        private Long id;
        private String name;
        private String brand;
        private BigDecimal price;
        private String mainImage;
        private Integer stock;
        private Long salesCount;
        private Integer status;
        private String statusDesc;
    }
    
    /**
     * 商品详情VO
     */
    @Data
    public static class ProductDetailVO {
        private Long id;
        private String name;
        private Long categoryId;
        private String categoryName;
        private String brand;
        private BigDecimal price;
        private Integer stock;
        private String description;
        private String mainImage;
        private List<String> images;
        private Long salesCount;
        private LocalDateTime createTime;
        
        // 相关商品
        private List<ProductListVO> relatedProducts;
    }
    
    /**
     * 设置状态描述
     */
    public void setStatusDesc() {
        if (this.status != null) {
            this.statusDesc = this.status == 1 ? "上架" : "下架";
        }
    }
}